<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>案例-遮罩交互</title>
    <style>
        .div1 {
            margin-top: 20px;
            width: 300px;
            margin: 0 auto;
            display: flex;
            flex-wrap: wrap;
            gap: 10px;
        }

        .div1 div {
            position: relative;
            width: 300px;
            height: 200px;
            overflow: hidden;
            border-radius: 5%;
            /* 添加边框圆角到容器 */
        }

        .div1 div img {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            object-fit: cover;
            z-index: 2;
            transition: opacity 0.3s ease, transform 0.3s ease;
        }

        .div2 {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background-color: rgba(0, 0, 0, 0.7);
            /* 使用半透明背景颜色 */
            border-radius: 5%;
            color: aliceblue;
            text-align: center;
            padding-top: 30px;
            overflow: hidden;
            z-index: 1;
            opacity: 0;
            transition: opacity 0.3s ease;
        }

        .div1 div:hover img {
            opacity: 0.5;
            transform: scale(1.2, 1.2);


            /* 调整图片透明度 */
        }

        .div1 div:hover .div2 {
            opacity: 1;
        }
    </style>
</head>

<body>
    <div class="div1">
        <div>
            <img src="https://www.loliapi.com/acg/">
            <div class="div2">
                <h2>图片 1 标题</h2>
                <p>这是图片 1 的详细描述信息</p>
            </div>
        </div>
        <div>
            <img src="https://www.loliapi.com/acg/">
            <div class="div2">
                <h2>图片 2 标题</h2>
                <p>这是图片 2 的详细描述信息</p>
            </div>
        </div>
    </div>
</body>

</html>